﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace Colorful.Furniture.PermissionManagement
{
    /// <summary>
    ///  同步资源请求体
    /// </summary>
    public class SyncResourceInputDto
    {
        /// <summary>
        ///  资源名字
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        ///  标签
        /// </summary>
        public MetaInputDto Meta { get; set; }

        /// <summary>
        ///  是否隐藏
        /// </summary>
        public bool Hidden { get; set; }

        /// <summary>
        ///  资源类型
        /// </summary>
        [JsonIgnore]
        public ResourceType ResourceType { get; set; } = ResourceType.管理端资源;

        /// <summary>
        ///  资源分类
        /// </summary>
        public int Category { get; set; } = 1;

        /// <summary>
        ///  路径
        /// </summary>
        public string Path { get; set; }

        /// <summary>
        ///  子集
        /// </summary>
        public List<SyncResourceInputDto> Children { get; set; }
    }

    /// <summary>
    ///  资源分类
    /// </summary>
    public enum ResourceType
    {
        /// <summary>
        ///  管理端资源
        /// </summary>
        管理端资源 = 1,

        /// <summary>
        ///  微信小程序资源
        /// </summary>
        微信小程序资源 = 2,

        /// <summary>
        ///  公众号资源
        /// </summary>
        公众号资源 = 3
    }

    /// <summary>
    ///  标签
    /// </summary>
    public class MetaInputDto
    {
        /// <summary>
        /// 标题
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        ///  图标
        /// </summary>
        public string Icon { get; set; }

        /// <summary>
        ///  角色代码集合
        /// </summary>
        public List<string> Roles { get; set; }
    }

    /// <summary>
    ///  资源表格树输出体
    /// </summary>
    public class ResourceTableTreeOutputDto1
    {
        /// <summary>
        ///  编码
        /// </summary>
        public Guid Id { get; set; }

        /// <summary>
        ///  是否全选
        /// </summary>
        public bool IsCheckAll { get; set; }

        /// <summary>
        ///  排序
        /// </summary>
        public int Sort { get; set; }

        /// <summary>
        ///  父级编码
        /// </summary>
        public Guid? ParentId { get; set; }

        /// <summary>
        ///  标题
        /// </summary>
        public string Label { get; set; }

        /// <summary>
        ///  名字（前端对应的是Code）
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        ///  子集
        /// </summary>
        public virtual List<ResourceTableTreeOutputDto1> Children { get; set; }

        /// <summary>
        ///  权限列表
        /// </summary>
        public virtual List<ResourcePermissionOutputDto1> Permissions { get; set; }
    }

    /// <summary>
    /// 资源表格树输出体
    /// </summary>
    public class ResourceTableTreeOutputDto: ResourceTableTreeOutputDto1
    {
        /// <summary>
        ///  不确定状态
        /// </summary>
        public bool IsIndeterminate { get; set; }

        /// <summary>
        ///  是否拥有权限
        /// </summary>
        public bool IsHasPermission { get; set; }

        /// <summary>
        ///  子集
        /// </summary>
        public new  List<ResourceTableTreeOutputDto> Children { get; set; }

        /// <summary>
        ///  权限列表
        /// </summary>
        public new List<ResourcePermissionOutputDto> Permissions { get; set; }
    }

    /// <summary>
    ///  资源权限输出体
    /// </summary>
    public class ResourcePermissionOutputDto1
    {
        /// <summary>
        ///  权限编码
        /// </summary>
        public Guid? Id { get; set; }

        /// <summary>
        ///  资源编码
        /// </summary>
        public Guid? ResourceId { get; set; }

        /// <summary>
        ///  是否选中
        /// </summary>
        public bool IsChecked { get; set; }

        /// <summary>
        ///  操作名字
        /// </summary>
        public string OperationTitle { get; set; }

        /// <summary>
        ///  操作代码
        /// </summary>
        public string OperationName { get; set; }
    }

    /// <summary>
    ///  资源权限输出体
    /// </summary>
    public class ResourcePermissionOutputDto: ResourcePermissionOutputDto1
    {
        /// <summary>
        ///  操作代码
        /// </summary>
        public string OperationName { get; set; }

        /// <summary>
        ///  操作排序
        /// </summary>
        public int OperationSort { get; set; }

        /// <summary>
        ///  接口数量
        /// </summary>
        public int? ApiCount { get; set; }
    }
}